<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateShopPayments extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('shop_payments', function (Blueprint $table) {
            $table->id();
            $table->unsignedTinyInteger('shopId')->default(0)->comment('店铺id');
            $table->string('paymentName', 50)->default('')->comment('支付方式名称');
            $table->unsignedTinyInteger('payChannel')->default(0)->comment('支付渠道');
            $table->unsignedTinyInteger('isOpen')->default(1)->comment('支付开关，1为开启，0为关闭');
            $table->text('payConfig')->comment('支付配置json');
            $table->unsignedTinyInteger('sort')->default(255)->comment('排序');
            $table->unsignedTinyInteger('isDeleted')->default(0)->comment("是否删除 0：未删除，1：已删除");
            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedAt')->default(0)->comment('修改时间');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('修改人');

            $table->index('shopId', 'idx_shopId');
            $table->index('payChannel', 'idx_payChannel`');

            $table->collation = 'utf8mb4_general_ci';
        });

        $prefix = config('other.DB_PREFIX', '');
        \Illuminate\Support\Facades\DB::statement("ALTER TABLE `{$prefix}shop_payments` COMMENT = '店铺支付配置表'"); //表注释
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('shop_payments');
    }
}
